﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBA.DataBaseAccess
{
    public enum SQLServerVer
    {
        EnterPrise = 0,
        Express = 1,
        Developer = 2
    }


    public class DBConfig
    {
        private string DBServerIP;
        private string ConnnectionString;

        private string ConnnectionString_EP = "Data Source=127.0.0.1; Initial Catalog=FundManageSystemDB;User ID=sa;pwd=;Connect Timeout=200; pooling='true'; Max Pool Size=200";
        private string ConnnectionString_EX = "Server=ROBERTSCOMPUTER\\SQLExpress;AttachDbFilename=F:\\Codes\\WinForm c#\\FundManageSystem\\DB\\FundManageSystemDB.mdf; Database=FundManageSystemDB;Trusted_Connection=Yes;";

        public DBConfig()
        {
            this.DBServerIP = "127.0.0.1";
            this.ConnnectionString = ConnnectionString_EP;
        }

        public DBConfig(string serverip, SQLServerVer ver, string dbname, string userid, string pwd)
        {
            this.DBServerIP = serverip;
            if (ver == SQLServerVer.EnterPrise || ver == SQLServerVer.Developer)
                this.ConnnectionString = "Data Source=" + this.DBServerIP +
                    "; Initial Catalog=" + dbname +
                    ";User ID=" + userid +
                    ";pwd=" + pwd +
                    ";Connect Timeout=200; pooling='true'; Max Pool Size=200";
            else if (ver == SQLServerVer.Express)
                this.ConnnectionString = this.ConnnectionString_EX;
        }
        public DBConfig(string serverip, SQLServerVer ver)
        {
            this.DBServerIP = serverip;
            if (ver == SQLServerVer.EnterPrise)
                this.ConnnectionString = this.ConnnectionString_EP;
            else if (ver == SQLServerVer.Express)
                this.ConnnectionString = this.ConnnectionString_EX;
        }

        public DBConfig(string serverip, SQLServerVer ver, string dbfilename)
        {
            this.DBServerIP = serverip;
            if (ver == SQLServerVer.EnterPrise)
                this.ConnnectionString = this.ConnnectionString_EP;
            else if (ver == SQLServerVer.Express)
            {
                this.ConnnectionString = "Server=ROBERTSCOMPUTER\\SQLExpress;AttachDbFilename=" +
                    dbfilename + "; Database=FundManageSystemDB;Trusted_Connection=Yes;";
            }
        }
        public string GetConnString()
        {
            return this.ConnnectionString;
        }

    }
}
